<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>7_2_2-1-监听响应式变量</title>
</head>

<body>


    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>


    <div id="Application">

    </div>
    <script>
        const App = Vue.createApp({
            setup() {
                let a = Vue.ref(1);
                Vue.watchEffect(() => {
                    //当变量a变化时，即执行当前函数
                    console.log("变量a变化了")
                    console.log(a.value)
                })
                a.value = 2;
                return {
                    a
                }
            }
        })
        App.mount("#Application")
    </script>
</body>

</html>